﻿@{
    ViewData["Title"] = "甜糖星愿自动收取";
}

<div class="container">
    <div class="row">
        <div class="col-sm-6" id="div-login">
            <div>
                <h1 class="title text-center">获取Token</h1>
                <form class="border padding-top">
                    <!-- region 图片验证码 -->
                    <div class="form-group row align-items-center margin-left-right">
                        <label for="captcha_code" class="col-4 col-form-label text-right no-left-padding">图片验证码</label>
                        <div class="col-4 no-left-padding">
                            <input type="text"
                                   class="form-control"
                                   id="captcha_code"
                                   name="captcha_code"
                                   autocomplete="off"
                                   onkeyup="this.value=this.value.replace(/\D/g,'')"
                                   onafterpaste="this.value=this.value.replace(/\D/g,'')"/>
                        </div>
                        <div class="col-4 no-left-padding">
                            <input type="button" class="btn-block" id="get_captcha_image" value="获取图片验证码" onclick="getCaptchaImage()"/>
                        </div>
                    </div>
                    <div id="captcha_div"
                         style="display: none"
                         class="form-group row align-items-center margin-left-right">
                        <img id="captcha_image" src="" alt=""/>
                    </div>
                    <input type="text"
                           id="captcha_id"
                           name="captcha_id"
                           style="display: none"/>
                    <!-- endregion -->

                    <div class="form-group row align-items-center margin-left-right">
                        <label for="phone_number" class="col-4 col-form-label text-right no-left-padding">手机号码</label>
                        <div class="col-4 no-left-padding">
                            <input type="text"
                                   class="form-control"
                                   id="phone_number"
                                   name="phone_number"
                                   autocomplete="off"
                                   onkeyup="this.value=this.value.replace(/\D/g,'')"
                                   onafterpaste="this.value=this.value.replace(/\D/g,'')"/>
                        </div>
                        <div class="col-4 no-left-padding">
                            <input type="button" class="btn-block" id="get_sms_code" value="获取手机验证码" onclick="sendSMSCode()"/>
                        </div>
                    </div>
                    <div class="form-group row align-items-center margin-left-right">
                        <label for="sms_code" class="col-4 col-form-label text-right no-left-padding">短信验证码</label>
                        <div class="col-4 no-left-padding">
                            <input type="text" id="sms_code" name="sms_code" autocomplete="off" class="form-control"/>
                        </div>
                        <div class="col-4 no-left-padding">
                            <input type="button" class="btn-block" id="verify_sms_code" value="登录" onclick="verifySMSCode()"/>
                        </div>
                    </div>
                    <hr class="margin-left-right"/>
                    <div class="form-group row align-items-center margin-left-right">
                        <label for="current_phone_number" class="col-6 col-form-label text-right no-left-padding">当前登录的手机号：</label>
                        <div class="col-4 no-left-padding">
                            <input type="text" readonly disabled class="form-control-plaintext" id="current_phone_number" value="">
                        </div>
                    </div>
                </form>
            </div>
            <div>
                <h1 class="title text-center">手动执行操作</h1>
                <form class="border padding-top">
                    <div class="form-group row margin-left-right">
                        <div class="col">
                            <input type="button" class="btn-block" id="signin" value="手动签到" onclick="manualSignin()">
                        </div>
                        <div class="col">
                            <input type="button" class="btn-block" id="signin" value="手动收取星愿" onclick="manualHarvest()">
                        </div>
                    </div>
                    <div class="form-group row margin-left-right">
                        <div class="col">
                            <input type="button" class="btn-block" id="signin" value="手动激活电费卡" onclick="manualCheckAndApplyElectricBillBonus()">
                        </div>
                        <div class="col">
                            <input type="button" class="btn-block" id="signin" value="手动刷新token" onclick="manualRefreshLogin()">
                        </div>
                    </div>
                </form>
            </div>
        </div>
        <div class="col-sm-6" id="div-push-keys">
            <div>
                <h1 class="title text-center">注册通知通道</h1>
                <form class="border padding-top padding-left-right">
                    <div class="accordion padding-bottom" id="notification_channels_accordion">
                        <!-- region ServerChan -->
                        <div class="card border-bottom">
                            <div class="card-header" id="header_server_chan">
                                <h2 class="mb-0">
                                    <button class="btn btn-link collapsed"
                                            type="button"
                                            data-toggle="collapse"
                                            data-target="#server_chan_configuration"
                                            aria-expanded="false"
                                            aria-controls="server_chan_configuration">
                                        Server酱
                                    </button>
                                </h2>
                            </div>
                            <div id="server_chan_configuration"
                                 class="collapse"
                                 aria-labelledby="header_server_chan">
                                <div class="card-body">
                                    <label for="server_chan_send_key">Send key</label>
                                    <input autocomplete="off" class="form-control" id="server_chan_send_key" name="server_chan_send_key" type="text"/>
                                </div>
                            </div>
                        </div>
                        <!-- endregion -->

                        <!-- region Bark -->
                        <div class="card border-bottom">
                            <div class="card-header" id="header_bark">
                                <h2 class="mb-0">
                                    <button class="btn btn-link collapsed"
                                            type="button"
                                            data-toggle="collapse"
                                            data-target="#bark_configuration"
                                            aria-expanded="false"
                                            aria-controls="bark_configuration">
                                        Bark
                                    </button>
                                </h2>
                            </div>
                            <div id="bark_configuration"
                                 class="collapse"
                                 aria-labelledby="header_bark">
                                <div class="card-body">
                                    <label for="bark_token">Token</label>
                                    <input autocomplete="off" class="form-control" id="bark_token" name="bark_token" type="text"/>
                                </div>
                            </div>
                        </div>
                        <!-- endregion -->

                        <!-- region DingTalk -->
                        <div class="card border-bottom">
                            <div class="card-header" id="header_ding_talk">
                                <h2 class="mb-0">
                                    <button class="btn btn-link collapsed"
                                            type="button"
                                            data-toggle="collapse"
                                            data-target="#ding_talk_configuration"
                                            aria-expanded="false"
                                            aria-controls="ding_talk_configuration">
                                        钉钉机器人
                                    </button>
                                </h2>
                            </div>
                            <div id="ding_talk_configuration"
                                 class="collapse"
                                 aria-labelledby="header_ding_talk">
                                <div class="card-body">
                                    <label for="dingtalk_token">Access Token</label>
                                    <input autocomplete="off" class="form-control" id="dingtalk_token" name="dingtalk_token" type="text"/>

                                    <label for="dingtalk_secret">Secret</label>
                                    <input autocomplete="off" class="form-control" id="dingtalk_secret" name="dingtalk_secret" type="text"/>

                                    <hr/>
                                    <div class="col-12 text-center">
                                        <lable>钉钉机器人的 access token 和 secret 必须同时设定</lable>
                                        <br/>
                                        <lable>否则通知将无法发送</lable>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <!-- endregion -->
                    </div>

                    <div class="form-group row align-items-center margin-left-right">
                        <div class="col-6">
                            <input class="btn-block" type="button" id="update_keys" value="更新" onclick="updateNotificationKeys()"/>
                        </div>
                        <div class="col-6">
                            <input class="btn-block" type="button" id="test_notification" value="测试" onclick="testNotificationKeys()"/>
                        </div>
                    </div>
                    <hr class="margin-left-right"/>
                    <div class="form-group col-12 text-center">
                        <lable>测试前需要先执行更新操作</lable>
                        <br/>
                        <lable>留空后更新即可删除对应通知通道</lable>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>